package com.hfut.jpoa.dao.impl;

import java.sql.SQLException;

import com.hfut.jpoa.common.exception.DaoException;
import com.hfut.jpoa.dao.ReturnVisitDAO;
import com.hfut.jpoa.model.ReturnVisit;
import com.ibatis.sqlmap.client.SqlMapClient;

public class ReturnVisitDAOImpl implements ReturnVisitDAO {
    private SqlMapClient sqlMapClient;

    

    public int deleteByPrimaryKey(String returnId) throws DaoException {
        ReturnVisit key = new ReturnVisit();
        key.setReturnId(returnId);
        int rows = 0;
        try {
            rows = sqlMapClient.delete("tb_jpoa_return.ibatorgenerated_deleteByPrimaryKey", key);
        }
        catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return rows;
    }

    public void insert(ReturnVisit record) throws DaoException {
        try {
            sqlMapClient.insert("tb_jpoa_return.ibatorgenerated_insert", record);
        }
        catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    public void insertSelective(ReturnVisit record) throws DaoException {
        try {
            sqlMapClient.insert("tb_jpoa_return.ibatorgenerated_insertSelective", record);
        }
        catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    public ReturnVisit selectByPrimaryKey(String returnId) throws DaoException {
        ReturnVisit key = new ReturnVisit();
        key.setReturnId(returnId);
        ReturnVisit record = null;
        try {
            record = (ReturnVisit) sqlMapClient.queryForObject("tb_jpoa_return.ibatorgenerated_selectByPrimaryKey", key);
        }
        catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return record;
    }

    public int updateByPrimaryKeySelective(ReturnVisit record) throws DaoException {
        int rows = 0;
        try {
            rows = sqlMapClient.update("tb_jpoa_return.ibatorgenerated_updateByPrimaryKeySelective", record);
        }
        catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return rows;
    }

    public int updateByPrimaryKey(ReturnVisit record) throws DaoException {
        int rows = 0;
        try {
            rows = sqlMapClient.update("tb_jpoa_return.ibatorgenerated_updateByPrimaryKey", record);
        }
        catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return rows;
    }

    /**
    * @param 对sqlMapClient进行赋值
    */
    public void setSqlMapClient(SqlMapClient sqlMapClient) {
        this.sqlMapClient = sqlMapClient;
    }
}